#include "mylabel.h"
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QLabel>
#include <QMouseEvent>
#include <QMovie>
mylabel::mylabel(QWidget *parent) : QLabel(parent)
{

}
//void mylabel::enterEvent(QEvent *event)
//{
//    //qDebug()<<"鼠标进入";
//}

//void mylabel::moveEvent(QMoveEvent *event)
//{
//    //qDebug()<<"鼠标离开";
//}


//void mylabel::mousePressEvent(QMouseEvent *event)
//{

//    if(Qt::LeftButton&event->button())
//    {
//      //qDebug()<<"鼠标按键按下";

//    }
//}


//void mylabel::mouseReleaseEvent(QMouseEvent *event)
//{
//    Widget* w=new Widget();
//    if(Qt::LeftButton&event->button())
//    {
//      //qDebug()<<"鼠标按键释放";
//      //QPixmap pixmap;
//      //pixmap.load("C:\\Users\\22509\\Pictures\\2.JPG");
//      //w->ui->label->setPixmap(pixmap);
//    }
//}

//void mylabel::mouseMoveEvent(QMouseEvent *event)
//{
//    Widget* w=new Widget();
//    w = (Widget *)parentWidget();
//    if(Qt::LeftButton&event->buttons())
//    {
//      //qDebug()<<"鼠标移动";
//      //w->ui->label_5->move(event->x(),event->y());
//    }
//}

void mylabel::mouseDoubleClickEvent(QMouseEvent *event)
{
    static int index=0;
    //双击时输出当前鼠标坐标
    //qDebug()<<"鼠标双击"<<QString("%1,%2").arg(event->x()).arg(event->y());
    Widget* w=new Widget();
    w = (Widget *)parentWidget();
    if(Qt::LeftButton&event->button())
    {
      qDebug()<<"鼠标按键按下";
      QMovie *movie=new QMovie();

      if(index==0)
      {
          movie->setFileName("C:\\Users\\22509\\Pictures\\bg2.gif");
          w->ui->bg->setMovie(movie);
          movie->start();
          w->ui->bg->setScaledContents(true);
          index++;
      }
      else if(index==1)
      {
          movie->setFileName("C:\\Users\\22509\\Pictures\\bg5.gif");
          w->ui->bg->setMovie(movie);
          movie->start();
          w->ui->bg->setScaledContents(true);
          index++;
      }
      else if(index==2)
      {
          movie->setFileName("C:\\Users\\22509\\Pictures\\bg6.gif");
          w->ui->bg->setMovie(movie);
          movie->start();
          w->ui->bg->setScaledContents(true);
          index++;
      }
      else if(index==3)
      {
          movie->setFileName("C:\\Users\\22509\\Pictures\\blackboard.gif");
          w->ui->bg->setMovie(movie);
          movie->start();
          w->ui->bg->setScaledContents(true);
          index=0;
      }

      }

}

